<?php defined('NABU') || exit ?>

<h1><?= $head_title ?></h1>

<?php require_once 'views/layouts/messages.php' ?>

<form method="post" action="<?= NABU_ROUTES['edit_profile'] ?>" enctype="multipart/form-data">
  <fieldset>
    <legend>Perfil</legend>
      <input type="hidden" name="csrf" value="<?= $token ?>">
      <div>
        <div>
          <label for="avatar"><b>Editar imagen de perfil</b></label>
        </div>
        <div>
          <img src="<?= $user['avatar'] ?>" alt="Foto de perfil" width="8%">
        </div>
        <div>
          <input type="file" id="avatar" name="avatar" accept="<?= NABU_DEFAULT['image_formats'] ?>">
        </div>
      </div>
      <div>
        <div>
          <label for="background"><b>Editar fondo de perfil</b></label>
        </div>
        <div>
          <img src="<?= $user['background'] ?>" alt="Fondo de perfil" width="32%">
        </div>
        <div>
          <input type="file" id="background" name="background" accept="<?= NABU_DEFAULT['image_formats'] ?>">
        </div>
      </div>
      <div>
        <div>
          <label for="description"><b>Descripción</b></label>
        </div>
        <div>
          <textarea id="description" name="description" maxlength="255" rows="5" cols="51"><?= $user['description'] ?></textarea>
        </div>
      </div>
  </fieldset>
  <fieldset>
    <legend>Datos personales</legend>
      <div>
        <label for="name"><b>Nombre completo</b></label>
        <input type="text" id="name" name="name" minlength="5" maxlength="255" value="<?= $user['name'] ?>">
      </div>
      <div>
        <label for="username"><b>Apodo</b></label>
        <input type="text" id="username" name="username" minlength="1" value="<?= $user['username'] ?>" maxlength="255">
      </div>
      <div>
        <label for="password"><b>Nueva constraseña</b></label>
        <input type="password" id="password" name="password" minlength="6" maxlength="255">
      </div>
      <div>
        <label for="password_confirm"><b>Confirmar contraseña</b></label>
        <input type="password" id="password_confirm" name="password_confirm" minlength="6" maxlength="255">
      </div>
  </fieldset>
    <div>
      <button><a href="<?= NABU_ROUTES['delete_profile'] ?>">Eliminar cuenta</a></button>
      <input type="submit" name="edit_profile_submit" value="Guardar">
    </div>
</form>
